package com.example.usermanagement.liuka.controller;

import com.example.usermanagement.exception.ObjectNotException;
import com.example.usermanagement.exception.ParamErrorException;
import com.example.usermanagement.liuka.model.FlowLog;
import com.example.usermanagement.liuka.service.FlowLogService;
import com.example.usermanagement.vo.FlowReportVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.List;


/**
 * 日志记录
 */
@RestController
@RequestMapping("/flow-log")
@Validated
public class FlowLogController {

    private FlowLogService flowLogService;


    @Autowired
    public FlowLogController(FlowLogService flowLogService){
        this.flowLogService = flowLogService;
    }


    /**
     *  流量使用日志
     * @param flowUserId  购买用户id
     * @param flowSize 使用流量
     * @return
    **/
    @PostMapping()
    public void addLog( Long flowUserId, BigDecimal flowSize) throws ObjectNotException, ParamErrorException {
         flowLogService.addFlow(flowUserId,flowSize);
    }


    /**
     * 报表
     * @return
    **/
    @GetMapping()
    public List<FlowReportVO> reportVOList(){
        return flowLogService.reportList();
    }
}
